package com.shujia.util

import java.io.StringReader

import org.wltea.analyzer.core.IKSegmenter

import scala.collection.mutable.ListBuffer

object IKUtil {
  def fit(str: String): List[String] = {
    val list = new ListBuffer[String]
    val sr = new StringReader(str)
    val ik = new IKSegmenter(sr, true)
    var next = ik.next()
    while (next != null) {
      val word = next.getLexemeText
      list.append(word)
      next = ik.next()
    }
    list.toList
  }

  def main(args: Array[String]): Unit = {
    val str = "今天天气很差，我想睡觉"
    println(fit(str))

  }

}
